#include <stdio.h>
#include <process.h>
#include <Windows.h>
#include "Person.h"

unsigned WINAPI PrintPerson(void* p)
{
    Person* person = (Person*)p;
    while(1)
        printf("%s\n", person->print().c_str());    
    
    return 0;
}

int main()
{
    HANDLE hThread[3];
    unsigned dwThreadID;
    Person* p = new Person("Alice", "Alaska");
    
    hThread[0] = (HANDLE)_beginthreadex(NULL,0,PrintPerson,p,0,&dwThreadID);
    hThread[1] = (HANDLE)_beginthreadex(NULL,0,PrintPerson,p,0,&dwThreadID);
    hThread[2] = (HANDLE)_beginthreadex(NULL,0,PrintPerson,p,0,&dwThreadID);

    WaitForMultipleObjects(3, hThread,1,INFINITE);

    delete p;

    return 0;
}